/*
 * BackSubPkt.cpp
 *
 *  Created on: Dec 13, 2011
 *      Author: andrea
 */

#include "BackSubPkt.h"

BackSubPkt::BackSubPkt(int parEventType, float parWindow, OccurrenceType parOccurrence) {

	eventType = parEventType;
	constraintsNum = 0;
	//SubPkt(parEventType);
	window = parWindow;
	occurrence = parOccurrence;


}

BackSubPkt::BackSubPkt(int parEventType, Constraint *parConstraints, int parConstraintsNum, float parWindow, OccurrenceType parOccurrence) {

	eventType = parEventType;
	constraintsNum = parConstraintsNum;
	constraints = new Constraint[constraintsNum];
	for (int i=0; i<constraintsNum; i++) constraints[i]=parConstraints[i];
	//SubPkt(parEventType, parConstraints, parConstraintsNum);
	window = parWindow;
	occurrence = parOccurrence;

}

BackSubPkt::BackSubPkt(const BackSubPkt &pkt) {
	eventType = pkt.eventType;
	constraintsNum = pkt.constraintsNum;
	if (constraintsNum>0) {
		constraints = new Constraint[constraintsNum];
		for (int i=0; i<constraintsNum; i++) constraints[i]=pkt.constraints[i];
	}
	window = pkt.window;
	occurrence = pkt.occurrence;
	timeStamp = pkt.timeStamp;
}

BackSubPkt::~BackSubPkt() {
	if (constraintsNum>0) delete [] constraints;
}


void BackSubPkt::setCurrentTime() {
	TimeMs currentTime;
	timeStamp = currentTime;
}

BackSubPkt * BackSubPkt::copy() {
	return new BackSubPkt(eventType, constraints, constraintsNum, window, occurrence);
}
